package edu.mapi.aamas.renderer;

import javax.swing.JFrame;

import jade.core.Agent;
import edu.mapi.aamas.behaviors.StateChangeListener;
import edu.mapi.aamas.behaviors.UpdateState;
import edu.mapi.aamas.common.VehicleState;

/**
 * 
 * @author rjpg
 *
 */

public class RenderAgent extends Agent implements StateChangeListener{
	Renderer3D render3D;
	
	public RenderAgent()
	{
		Camera3D cs[]=new Camera3D[1];  //escolher uma cam de lado 
   		cs[0]=new Camera3D(Camera3D.USER);  //top
   		  		
   		render3D=new Renderer3D(cs,(short)1,(short)1);  // 1 por 1
   		
   		
	}

	public Renderer3D getRender3D() {
		return render3D;
	}

	public void setRender3D(Renderer3D render3D) {
		this.render3D = render3D;
	}

	
	public void receiveMessage(VehicleState state) {
		render3D.newState(state);
	}
	
	protected void setup() {
		super.setup();
		
		UpdateState update = new UpdateState();
		update.addStateChange(this);
		addBehaviour(update);
		JFrame frame = new JFrame("World Renderer");
		frame.getContentPane().add(render3D);
		frame.setSize(400, 300);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setVisible(true);
	}
}
